package com.cxyzy.demo

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.Composable
import androidx.compose.ambient
import androidx.compose.unaryPlus
import androidx.ui.core.ContextAmbient
import androidx.ui.core.setContent
import androidx.ui.material.Button
import androidx.ui.tooling.preview.Preview

class FirstActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContent用于设置整体页面内容
        setContent {
            firstPage()
        }
    }
}

@Preview
@Composable
fun firstPage() {
    val context = +ambient(ContextAmbient)
    //Button函数用于显示按钮
    Button(text = "点击查看第二页", onClick = {
        context.startActivity(Intent(context, SecondActivity::class.java))
    })
}